package com.example.demo02.Swaggerdemo;

import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;

@Service
public class UserService {
    /**
     * 模拟数据库数据
     */
    public static List<User> list = Arrays.asList(
            new User("杨竣淮","2023309294"),
            new User("张三","123"),
            new User("李四","456")
    );

    public List<User> findAllUsers() {
        return list;
    }

    public User findUserByName(String username) {
        for (User user:list) {
            if (user.getUsername().equals(username)) {
                return user;
            }
        }
        return null;
    }
}
